<?php 
include 'init.php';
$sql = array();

$sql[] = "ALTER TABLE `picture_category_locale` ADD `parent_id` INT( 11 ) NOT NULL DEFAULT '0' AFTER `category_id` ,
		ADD INDEX ( `parent_id` );";
$sql[] = "ALTER TABLE `picture_category_locale` ADD `display_order` INT( 10 ) NOT NULL DEFAULT '0' AFTER `title` ,
		ADD INDEX ( `display_order` );";
$sql[] = "ALTER TABLE `picture_category_locale` ADD `is_active` TINYINT( 1 ) NOT NULL DEFAULT '1' AFTER `display_order` ,
		ADD INDEX ( `is_active` );";

foreach(system_db::getAdapter()->fetchAll("SELECT * FROM `picture_category` ORDER BY `id` ASC") AS $category) {
	
	$parent_id = $category['parent_id'];
	$display_order = $category['display_order'];
	$is_active = $category['is_active'];
	$category_id = $category['id'];
	foreach(new system_setting_language() AS $lang) {
		$_lang = strtolower($lang->getKey());
		$sql[] = "UPDATE `picture_category_locale` SET `parent_id` = '$parent_id', `display_order` = '$display_order', `is_active` = '$is_active'
				WHERE `category_id` = '$category_id' AND `lang` = '$_lang';";
	}
	
}
$sql[] = "ALTER TABLE `picture_category`  DROP `parent_id`,  DROP `display_order`,  DROP `is_active`;";

echo implode("\r\n", $sql);




?>